<?php
/******************************************
 * Author: <YOUR NAME HERE>
 * Description: <YOUR DESCRIPTION HERE>
 ******************************************/
class Recepta_helper extends CustomSecurity { 

	var $db; 
	var $recepta;
	var $product;
	var $kolichestvo;

	function Recepta_helper($db){ 
    }

	/***********************************
 	 * Add:         Allows the insertion of values into the Table.
 	 * Parameters:  $recepta, $product, $kolichestvo
 	 * Return:      (Boolean) True - Successfully Inserted | False - Error
 	 ************************************/
	function add($recepta, $product, $kolichestvo, $merna_edinica){ 

		escape_string($recepta);
		escape_string($product);
		escape_string($kolichestvo);
		escape_string($merna_edinica);
		
		$statement = "INSERT INTO recepta_helper (recepta, product, kolichestvo, merna_edinica) VALUES ('$recepta', '$product', '$kolichestvo', '$merna_edinica');";
		$results   = mysql_query($statement);

		if($results){
			return true;
		}else{
			return false;
		}

	}//End add()


	/***********************************
 	 * Remove:      Allows for the removal of record from the database.
 	 * Parameters:  (String)Primary Key Column Name | (Int) Primary Key Value
 	 * Return:      (Boolean) True - Successfully Removed | False - Error
 	 ************************************/
	function remove($primaryKeyValue){ 

		escape_string($primaryKeyValue);

		$statement = "DELETE FROM recepta_helper WHERE recepta = '$primaryKeyValue'";
		$results   = mysql_query($statement);
		if($results){
			return true;
		}else{
			return false;
		}

	}//End remove()


	/***********************************
 	 * Update:      Allows for the update of a record from the database.
 	 * Parameters:  (String)Primary Key Column Name | (Int) Primary Key Value | (String) Column Name To Update | (String) New Value
 	 * Return:      (Boolean) True - Successfully Updated | False - Error
 	 ************************************/
	function update($primaryKeyName, $primaryKeyValue, $columnNameToUpdate, $columnValue){ 

		escape_string($primaryKeyName);
		escape_string($primaryKeyValue);
		escape_string($columnNameToUpdate);
		escape_string($columnValue);

		$statement = "UPDATE recepta_helper SET $columnNameToUpdate = '$columnValue' WHERE $primaryKeyName = '$primaryKeyValue'";
		$results   = mysql_query($statement);
		if($results){
			return true;
		}else{
			return false;
		}

	}//End update()


	/***********************************
 	 * GetAll:       Returns all the records in the database.
 	 * Parameters:   NA
 	 * Return:      (MultiDimensional-Array)String
 	 ************************************/
	function getAll(){ 

		//Custom SQL Injection Escaping HERE

		$statement = "SELECT recepta, product, kolichestvo, merna_edinica FROM recepta_helper";
		$results   = mysql_query($statement);
		
		$tokens[0] = 'recepta';
		$tokens[1] = 'product';
		$tokens[2] = 'kolichestvo';
		$tokens[3] = 'merna_edinica';
		
		return transformResults($results, $tokens);

	}//End getAll()


	/***********************************
 	 * GetObject:   Returns a specific record form the batabase.
 	 * Parameters:  (Int) Primary Key Value
 	 * Return:      (Array)String
 	 ************************************/
	function getObject($primaryKeyValue){ 

		escape_string($primaryKeyValue);

		$statement = "SELECT product, kolichestvo, merna_edinica FROM recepta_helper WHERE recepta = '".$primaryKeyValue."'";
		$results   = mysql_query($statement);
		
		$tokens[0] = 'product';
		$tokens[1] = 'kolichestvo';
		$tokens[2] = 'merna_edinica';
		return transformResults($results, $tokens);

	}//End getObject()


}//End Class Recepta_helper
?>